let timerSign = null;

self.onmessage = function (event) {
  if (event.data === 'StartTimer') {
    StartTimer();
  } else if (event.data === 'StopTimer') {
    StopTimer();
  }
};

function StartTimer() {
  timerSign = setInterval(() => {
    self.postMessage({
      type: 'DetectPerSecond', // 每秒检测
      data: {},
    });
  }, 1000);
}
function StopTimer() {
  clearInterval(timerSign);
  timerSign = null;
}
